//
//  CMDBHomeReleatedPeople.swift
//  CMDB
//
//  Created by 曹桂祥 on 2017/5/5.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBHomeReleatedPeopleCell: CustomBaseCell {
    
    var corporateLabel : UILabel!
    
    var iconView : UIImageView!
    
    var nameLabel : UILabel!
    
    override func cellBuildSubViews() {
        
        iconView = UIImageView.getInstance()
        
        iconView.frame = CGRect(x: KleftMargin, y: KleftMargin, width: 80 * CMDB_Rate, height: 80 * CMDB_Rate)
        
        iconView.layer.cornerRadius = 3
        
        iconView.image = UIImage(named: "test头像")
        
        iconView.layer.masksToBounds = true
        
        contentView.addSubview(iconView)
        
        nameLabel = UILabel.getInstance()
        
        nameLabel.textColor = word87Color
        
        nameLabel.font = CMDB_16_Bold_FONT
        
        let testStr = "冯磊"
        
        nameLabel.text = testStr
        
        let size = testStr.suitToSize(MaxSize, boldFontSize: 16, lineSpacing: 1)
        
        nameLabel.frame = CGRect(x: KleftMargin + CGRectGetMaxX(iconView.frame), y: KleftMargin, width: 200, height: size.height)
        
        contentView.addSubview(nameLabel)
        
        setCorporateLabel()
        
        
        
        let singleView = UIView.CreateLine(CGRect(x: 0, y: 70.5, width: CMDB_Screen_Width, height: 0.5), lineColor: word12Color)
     
        contentView.addSubview(singleView)
    }
}


extension CMDBHomeReleatedPeopleCell{
    
    func setCorporateLabel(){
        
        corporateLabel = UILabel.getInstance()
        
        corporateLabel.numberOfLines = 0
        
        let text0 = "2622\n"
        
        let text2 = "关注"
        
        let para = NSMutableParagraphStyle()
        
        para.lineSpacing = 5
        
        let attr =  NSAttributedString(string: text0, attributes: [NSForegroundColorAttributeName : word87Color,NSFontAttributeName : CMDB_13_Bold_FONT,NSParagraphStyleAttributeName:para])
        
        corporateLabel.setAttr(attr)
        
        let attr2 = NSAttributedString(string: text2, attributes: [NSForegroundColorAttributeName : word54Color,NSFontAttributeName : CMDB_12_FONT,NSParagraphStyleAttributeName:para])
        
        corporateLabel.appendAttr(attr2)
        
        printLog(corporateLabel.attributedText)
        
        corporateLabel.sizeToFit()
        
        corporateLabel.frame = CGRect(x: CMDB_Screen_Width - corporateLabel.width - KleftMargin, y: KleftMargin, width: corporateLabel.width, height: corporateLabel.height)
        
        corporateLabel.textAlignment = .Center
        
        contentView.addSubview(corporateLabel)
        
    }
    
}